import Inject from "@entity-access/entity-access/dist/di/di.js"; import { Route } from "@entity-access/server-pages/dist/core/Route.js"; import Page from "@entity-access/server-pages/dist/Page.js"; import StorePaymentGatewayService from "../../../../../server/services/store/StorePaymentGatewayService.js"; import WebSiteContentService from "../../../../../server/services/files/WebSiteContentService.js"; import { storeAuthRedirect } from "../../storeAuthRedirect.js"; @storeAuthRedirect export default class extends Page { @Route orderID; @Inject pgs: StorePaymentGatewayService; @Inject wcs: WebSiteContentService; async run() { const [ pgAccountID ] = this.childPath as any[]; const { orderID } = this; const host = this.request.hostName; const w = await this.wcs.getWebSite(host); const storeID = w.folderID; const c = await this.pgs.checkout({ storeID, orderID, host, pgAccountID }); if (c.url) { return this.redirect(c.url); } if (c.url) { return this.redirect(c.url); } if(c.content) { return this.content({ body: c.content, contentType: "text/html" }); } return this.redirect("/store/order/" + orderID); } }